package com.ctakit.sdk.app.util;

import java.util.HashMap;
import java.util.Map;


public class MyNumberUtils{
	private static Map<Integer, String> unitMap = new HashMap<Integer, String>();
	private static Map<Integer, String> valueMap = new HashMap<Integer, String>();
	static {
		
		unitMap.put(0, "");
		unitMap.put(1, "十");
		unitMap.put(2, "百");
		unitMap.put(3, "千");
		unitMap.put(4, "万");
		unitMap.put(5, "十");
		unitMap.put(6, "百");
		unitMap.put(7, "千");
		unitMap.put(8, "亿");
		unitMap.put(9, "十");
		unitMap.put(10, "百");
		unitMap.put(11, "千");

		
		valueMap.put(1, "一");
		valueMap.put(2, "二");
		valueMap.put(3, "三");
		valueMap.put(4, "四");
		valueMap.put(5, "五");
		valueMap.put(6, "六");
		valueMap.put(7, "七");
		valueMap.put(8, "八");
		valueMap.put(9, "九");
		valueMap.put(0, "零");
	}
	public static int[] stringToInt(String s) {
		if (s.length() == 0) {
			System.out.println("please input the number");
			//System.exit(0);
		}
		int[] values = new int[s.length()];
		for (int i = 0; i < s.length(); i++) {
			if (!Character.isDigit(s.charAt(i))) {
				System.out.println("you input has none digt");
				//System.exit(0);
			}
			values[i] = Character.getNumericValue(s.charAt(i));

		}
		return values;
	}

	public static String conver(String s) {
		int[] money = stringToInt(s);
		String sb = "";
		int leg = money.length;
		for (int i = 0; i < leg; i++) {
			sb += valueMap.get(money[i]) + unitMap.get(leg - i - 1);
		}
		return sb;
	}


	public static boolean isInArray(int val,int[] array){
		boolean rs = false;
		for (int i = 0;i<array.length;i++){
			if(val==array[i]){
				rs = true;
				break;
			}
		}
		return rs;
	}


}
